
#include "Girl.h"
#include "GiftSenderProxy.h"
#include "GiftSenderConcrete.h"
#include <memory>
#include <utility>
#include <iostream>

using namespace npProxy;
using namespace std;

void doProxy()
{
    //girl
    shared_ptr<Girl> girl = make_shared<Girl>();
    girl->setName("xiubao");

    //gift sender
    shared_ptr<GiftSender> giftSender = make_shared<GiftSenderConcrete>(weak_ptr<Girl>(girl));

    //proxy
    shared_ptr<GiftSenderProxy> proxy = make_shared<GiftSenderProxy>(giftSender);

    // 抛出不同的枚举异常测试
    // try
    // {
    //     cout << "Exact exception is: GiftSenderProxy::ErrorEnum" << endl;
    //     proxy->sendDolls();
    // }
    // catch(const GiftSender::ErrorEnum& e1)
    // {
    //     cout << "exception caught: GiftSender::ErrorEnum" << endl;
    // }
    // catch(const GiftSenderProxy::ErrorEnum& e)
    // {
    //     cout << "exception caught. GiftSenderProxy::ErrorEnum" << endl;
    // }
    
    proxy->sendDolls();
    proxy->sendFollows();
    proxy->sendChocolates();
}
